package truedano.truedano;


import android.os.Bundle;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.graphics.Color;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TableLayout;

public class Truedano extends Activity {
	protected static final int REQUEST_CODE = 0;
	private Button button1;
	private OnClickListener	button1_listener	= null;
	public int now_bg_color=0;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.truedano);
		
		setListener();
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.truedano, menu);
		return true;
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data)
	{
		//Log.i("truedano","requestCode="+requestCode);
		//Log.i("truedano","REQUEST_CODE="+REQUEST_CODE);
		if (requestCode == REQUEST_CODE)
		{
			if (resultCode == RESULT_OK)
			{
				String temp = null;
				Bundle extras = data.getExtras();
				if (extras != null)
				{
					temp = extras.getString("FromActivity1");
				}
				setTitle(temp);
			}
		}
	}
	
	private void setListener(){
		Button button1 = (Button)findViewById(R.id.button1);
		button1.setOnClickListener(new Button.OnClickListener(){
    		@Override
    		public void onClick(View v) {
    			//Log.i("truedano","click button1");
    			Intent intent = new Intent(Truedano.this,Page01.class);
    			intent.putExtra("FromAppMain", "1111111111111111");
    			startActivityForResult(intent, REQUEST_CODE);
    		}
        });
		Button button2 = (Button)findViewById(R.id.button2);
		button2.setOnClickListener(new Button.OnClickListener(){
    		@Override
    		public void onClick(View v) {
    			//Log.i("truedano","click button2");
    			Intent intent = new Intent(Truedano.this,AppMain.class);
    			startActivityForResult(intent, REQUEST_CODE);
    		}
        });
		Button button3 = (Button)findViewById(R.id.button3);
		button3.setOnClickListener(new Button.OnClickListener(){
    		@Override
    		public void onClick(View v) {
    			//���I���C��
    			int color[]={Color.BLACK,Color.BLUE,Color.CYAN,Color.DKGRAY,Color.LTGRAY,Color.YELLOW};
    			
    			if(now_bg_color >= color.length)
    				now_bg_color = 0;
        		changeBgColor(R.id.back,color[now_bg_color]);
        		now_bg_color++;
        		//Log.i("truedano",""+now_bg_color);			
        		new MyUtil().ToastShow(getApplicationContext(), "now_bg_color="+now_bg_color);
    		}
        });
		Button button4 = (Button)findViewById(R.id.button4);
		button4.setOnClickListener(new Button.OnClickListener(){
    		@Override
    		public void onClick(View v) {
    			Intent intent = new Intent(Truedano.this,MyTextView.class);
    			startActivityForResult(intent, REQUEST_CODE);
    		}
        });
		Button btn_EditText = (Button)findViewById(R.id.btn_EditText);
		btn_EditText.setOnClickListener(new Button.OnClickListener(){
    		@Override
    		public void onClick(View v) {
    			Intent intent = new Intent(Truedano.this,MyEditText.class);
    			startActivityForResult(intent, REQUEST_CODE);
    		}
        });
		Button btn_CheckBox = (Button)findViewById(R.id.btn_CheckBox);
		btn_CheckBox.setOnClickListener(new Button.OnClickListener(){
    		@Override
    		public void onClick(View v) {
    			Intent intent = new Intent(Truedano.this,MyCheckBox.class);
    			startActivityForResult(intent, REQUEST_CODE);
    		}
        });
		Button btn_RadioButton = (Button)findViewById(R.id.btn_RadioButton);
		btn_RadioButton.setOnClickListener(new Button.OnClickListener(){
    		@Override
    		public void onClick(View v) {
    			Intent intent = new Intent(Truedano.this,MyRadioButton.class);
    			startActivityForResult(intent, REQUEST_CODE);
    		}
        });
		Button btn_FrameLayout = (Button)findViewById(R.id.btn_FrameLayout);
		btn_FrameLayout.setOnClickListener(new Button.OnClickListener(){
    		@Override
    		public void onClick(View v) {
    			Intent intent = new Intent(Truedano.this,MyFrameLayout.class);
    			startActivityForResult(intent, REQUEST_CODE);
    		}
        });
		Button btn_LinerLayout = (Button)findViewById(R.id.btn_LinerLayout);
		btn_LinerLayout.setOnClickListener(new Button.OnClickListener(){
    		@Override
    		public void onClick(View v) {
    			Intent intent = new Intent(Truedano.this,MyLinerLayout.class);
    			startActivityForResult(intent, REQUEST_CODE);
    		}
        });
		Button btn_RelativeLayout = (Button)findViewById(R.id.btn_RelativeLayout);
		btn_RelativeLayout.setOnClickListener(new Button.OnClickListener(){
    		@Override
    		public void onClick(View v) {
    			Intent intent = new Intent(Truedano.this,MyRelativeLayout.class);
    			startActivityForResult(intent, REQUEST_CODE);
    		}
        });
		Button btn_TableLayout = (Button)findViewById(R.id.btn_TableLayout);
		btn_TableLayout.setOnClickListener(new Button.OnClickListener(){
    		@Override
    		public void onClick(View v) {
    			Intent intent = new Intent(Truedano.this,MyTableLayout.class);
    			startActivityForResult(intent, REQUEST_CODE);
    		}
        });
		Button btn_ImageButton = (Button)findViewById(R.id.btn_ImageButton);
		btn_ImageButton.setOnClickListener(new Button.OnClickListener(){
    		@Override
    		public void onClick(View v) {
    			Intent intent = new Intent(Truedano.this,MyImageButton.class);
    			startActivityForResult(intent, REQUEST_CODE);
    		}
        });
        Button btn_DatePicker = (Button)findViewById(R.id.btn_DatePicker);
        btn_DatePicker.setOnClickListener(new Button.OnClickListener(){
    		@Override
    		public void onClick(View v) {
    			Intent intent = new Intent(Truedano.this,MyDatePicker.class);
    			startActivityForResult(intent, REQUEST_CODE);
    		}
        });
        Button btn_ListView1 = (Button)findViewById(R.id.btn_ListView1);
        btn_ListView1.setOnClickListener(new Button.OnClickListener(){
    		@Override
    		public void onClick(View v) {
    			Intent intent = new Intent(Truedano.this,MyListView.class);
    			startActivityForResult(intent, REQUEST_CODE);
    		}
        });
        Button btn_DataBase = (Button)findViewById(R.id.btn_DataBase);
        btn_DataBase.setOnClickListener(new Button.OnClickListener(){
    		@Override
    		public void onClick(View v) {
    			Intent intent = new Intent(Truedano.this,MyDataBase.class);
    			startActivityForResult(intent, REQUEST_CODE);
    		}
        });
        Button btn_Intent = (Button)findViewById(R.id.btn_Intent);
        btn_Intent.setOnClickListener(new Button.OnClickListener(){
    		@Override
    		public void onClick(View v) {
    			Intent intent = new Intent(Truedano.this,MyIntent.class);
    			startActivityForResult(intent, REQUEST_CODE);
    		}
        });
        Button btn_EditTextSave = (Button)findViewById(R.id.btn_EditTextSave);
        btn_EditTextSave.setOnClickListener(new Button.OnClickListener(){
    		@Override
    		public void onClick(View v) {
    			Intent intent = new Intent(Truedano.this,MyEditTextSave.class);
    			startActivityForResult(intent, REQUEST_CODE);
    		}
        });
	}
	
	public void changeBgColor(int id, int color){
		TableLayout bg = (TableLayout)findViewById(id);
		bg.setBackgroundColor(color);//���I���C��
	}
}

